package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.PingjiaLableBean;
import com.lwj.liwanjia.impl.PingjiaLableView;
import com.lwj.liwanjia.model.PingjiaLableModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/30.
 */

public class PingjiaLablePresenter {
    private PingjiaLableModel pingjiaLableModel;
    private PingjiaLableView pingjiaLableView;

    public PingjiaLablePresenter(PingjiaLableView pingjiaLableView) {
        this.pingjiaLableView = pingjiaLableView;
        pingjiaLableModel = new PingjiaLableModel();
    }

    public void getPingjiaLable(String token, String commodityCode, String commodityType) {
        if (pingjiaLableView != null) {
            pingjiaLableModel.getPingjiaLable(token, commodityCode, commodityType, new Subscriber<PingjiaLableBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    pingjiaLableView.showError((Exception) e);
                }

                @Override
                public void onNext(PingjiaLableBean pingjiaLableBean) {
                    pingjiaLableView.getPingjiaLable(pingjiaLableBean);
                }
            });
        }
    }
}
